# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: Sigmund Vestergaard <sigmundv at gmail dot com>

_gemname='http-cookie'
pkgname="ruby-${_gemname}"
pkgver=1.0.5
pkgrel=1
pkgdesc='Ruby library to handle HTTP Cookies based on RFC 6265'
arch=('any')
url="https://github.com/sparklemotion/${_gemname}"
license=('MIT')
makedepends=('ruby-rdoc' 'ruby-bundler')
checkdepends=('ruby-rake' 'ruby-test-unit' 'ruby-sqlite3')
depends=('ruby' 'ruby-domain_name')
options=(!emptydirs)
source=("${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
sha512sums=('89b7e7e3d72850cabb44b9c964a71c9a0ccfb4c74d3f151e5f60919c2106e0ff51bd12dda48b0960092e58473d02f2a9526cf94aec8970e596d514b03e475caf')

prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"

  # allow latest gem dependencies
  sed --in-place 's|git ls-files|find|' "${_gemname}.gemspec"

  # disable simplecov reporting.
  # it's not required and just adds another dependency
  sed --in-place '/simplecov_start.rb/d' Rakefile
  sed --in-place '/simplecov/d' "${_gemname}.gemspec"

  # Don't load rubygems.
  # It would require us to install all development gems
  sed --in-place '/rubygems/d' test/helper.rb
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rake test --trace
}

package() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
